package com.example.demo.controller;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.demo.entity.TbUser;
import com.example.demo.mapper.TbUserMapper;
import com.example.demo.record.UserRecord;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName BaseController
 * @Description:
 * @Author: hgq
 * @CreateDate: 2025/4/29 10:06
 * @UpdateUser: hgq
 * @UpdateDate: 2025/4/29 10:06
 * @UpdateRemark:
 * @Version: 1.0
 */
@RestController
@RequestMapping("/base")
@AllArgsConstructor
@Slf4j
public class BaseController {

    private TbUserMapper tbUserMapper;


    @GetMapping("/getById")
    public List<TbUser> queryByUserFunction(@RequestParam(value = "userId") String userId) {

        if (StrUtil.isEmpty(userId)) {
            throw new RuntimeException("用户编号不能为空");
        }
        log.info("根据条件查询用户>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>start");
        List<TbUser> list = tbUserMapper.selectList(null, new LambdaQueryWrapper<TbUser>()
                .eq(StrUtil.isNotEmpty(userId), TbUser::getId, userId)
        );

        log.info("根据条件查询用户>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>end");
        return list;
    }

}
